#pragma once


// CMultiListBox
#define MLN_ITEM_HILITE WM_USER+1
#define MLN_ITEM_CLICK WM_USER+2

using namespace std;

class CMultiListBox : public CWnd
{
        DECLARE_DYNAMIC(CMultiListBox)

    private:
        struct struct_data_entry
        {
            bool  hilite;
            CString  text1;
            CString  text2;
            COLORREF color;
            int   user_data;
        };


    public:
        CMultiListBox();
        virtual ~CMultiListBox();

        afx_msg void OnPaint();

        size_t  AddLine(const CString& title);
        size_t  AddText(size_t line, const CString& txt1,const CString& txt2, COLORREF color=0, int data = 0);

        void  SetItemData(size_t l, int subitem, int data);
        int   GetItemData(size_t l, int subitem);

        void  SetChecked(size_t l, int s, bool checked = true);
        bool  GetChecked(size_t l, int s);
        void  ClearChecked();

        bool  SetHiLite(size_t l, int s);
        void  GetHiLite(size_t& l, int& s);


        void DeleteContents();

        CRect GetItemRect(int line, int subitem);
        bool HitTest(CPoint point, int& line, int& subitem);

    private:
        afx_msg BOOL OnEraseBkgnd(CDC* pDC);
        afx_msg void OnSize(UINT nType, int cx, int cy);
        afx_msg void OnDestroy();
        afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);

        void CheckScrollBar();
        int  GetLineHeight();


    public:
        DECLARE_MESSAGE_MAP()


    private:
        vector <CString>    ms_data_title;
        vector <vector <struct_data_entry>> ms_data;

        int  mn_highlit_line;
        int  mn_highlit_subitem;

        afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
        afx_msg void OnMouseMove(UINT nFlags, CPoint point);
        afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
};


